/*
 * @Author: liushuai 
 * @Date: 2018-10-08 19:24:14 
 * @Last Modified by: liushuai
 * @Last Modified time: 2018-10-24 17:08:19
 */

//owl 选装
$(document).ready(function () {
  $("#owl-demo").owlCarousel({
    navigation: true,
    slideSpeed: 300,
    paginationSpeed: 400,
    singleItem: true

  });
});

function telNo(id) {
  var phone = document.getElementById(id).value;
  if (phone!=""){
      if (!(/^1[34578]\d{9}$/.test(phone))) {
          layer.msg('手机号码有误，请重填!');
          document.getElementById(id).value = '';
          return false;
      }
  }
}


//自定义选择框
$(function () {
  $('select.styled').customSelect();
});

//显示
function showbox() {
  $(".hidebox").show();
};

// 隐藏
function hidebox() {
  $(".hidebox").hide();
};

// 顶部Logo点击后效果优化
$('.logo').on('click', function () {
  $('.sidebar-menu li').removeClass('active');
  $('.sidebar-menu li:first-child').addClass('active');
  $('.sub li').removeClass('active');
});

// 显示帮助文档
function help() {
  $("#help").modal("show");
}

function imgbox(start) {
  var json = {
    "title": "帮助说明", //相册标题
    "id": 1, //相册id
    "start": start, //初始显示的图片序号，默认0
    "data": [ //相册包含的图片，数组格式
      {
        "alt": "登录页面",
        "pid": 0, //图片id
        "src": "img/log.png", //原图地址
        "thumb": "" //缩略图地址
      },
      {
        "alt": "账户设置",
        "pid": 1, //图片id
        "src": "img/pud.png", //原图地址
        "thumb": "" //缩略图地址
      },
      {
        "alt": "个人信息",
        "pid": 2, //图片id
        "src": "img/ptu.png", //原图地址
        "thumb": "" //缩略图地址
      },
      {
        "alt": "个人资产",
        "pid": 3, //图片id
        "src": "img/ptl.png", //原图地址
        "thumb": "" //缩略图地址
      },
      {
        "alt": "项目列表",
        "pid": 4, //图片id
        "src": "img/pro.png", //原图地址
        "thumb": "" //缩略图地址
      },
      {
        "alt": "项目管理",
        "pid": 5, //图片id
        "src": "img/prus.png", //原图地址
        "thumb": "" //缩略图地址
      },
      {
        "alt": "项目成员",
        "pid": 6, //图片id
        "src": "img/prun.png", //原图地址
        "thumb": "" //缩略图地址
      },
      {
        "alt": "项目整体进展",
        "pid": 7, //图片id
        "src": "img/prok.png", //原图地址
        "thumb": "" //缩略图地址
      },
      {
        "alt": "项目目标",
        "pid": 8, //图片id
        "src": "img/pstl.png", //原图地址
        "thumb": "" //缩略图地址
      },
      {
        "alt": "项目OKR",
        "pid": 9, //图片id
        "src": "img/okr.png", //原图地址
        "thumb": "" //缩略图地址
      },
      {
        "alt": "OKR进展",
        "pid": 10, //图片id
        "src": "img/okrp.png", //原图地址
        "thumb": "" //缩略图地址
      },
      {
        "alt": "项目线索总流程",
        "pid": 11, //图片id
        "src": "img/xs.png", //原图地址
        "thumb": "" //缩略图地址
      },
      {
        "alt": "战略类·立项流程",
        "pid": 12, //图片id
        "src": "img/lx1.png", //原图地址
        "thumb": "" //缩略图地址
      },
      {
        "alt": "销售类·立项流程",
        "pid": 13, //图片id
        "src": "img/lx2.png", //原图地址
        "thumb": "" //缩略图地址
      },
      {
        "alt": "部门类·立项流程",
        "pid": 14, //图片id
        "src": "img/lx3.png", //原图地址
        "thumb": "" //缩略图地址
      },
      {
        "alt": "事务类·立项流程",
        "pid": 15, //图片id
        "src": "img/lx4.png", //原图地址
        "thumb": "" //缩略图地址
      },
      {
        "alt": "测试类·立项流程",
        "pid": 16, //图片id
        "src": "img/lx5.png", //原图地址
        "thumb": "" //缩略图地址
      },
      {
        "alt": "研发类·立项流程",
        "pid": 17, //图片id
        "src": "img/lx6.png", //原图地址
        "thumb": "" //缩略图地址
      },
      {
        "alt": "项目需求流程",
        "pid": 18, //图片id
        "src": "img/xq.png", //原图地址
        "thumb": "" //缩略图地址
      },
      {
        "alt": "项目问题流程",
        "pid": 19, //图片id
        "src": "img/wt.png", //原图地址
        "thumb": "" //缩略图地址
      },
      {
        "alt": "项目投标流程",
        "pid": 20, //图片id
        "src": "img/tb.png", //原图地址
        "thumb": "" //缩略图地址
      },
      {
        "alt": "项目报价流程",
        "pid": 21, //图片id
        "src": "img/bj.png", //原图地址
        "thumb": "" //缩略图地址
      },
      {
        "alt": "项目合同流程",
        "pid": 22, //图片id
        "src": "img/ht.png", //原图地址
        "thumb": "" //缩略图地址
      },
      {
        "alt": "费用审批流程",
        "pid": 23, //图片id
        "src": "img/fy.png", //原图地址
        "thumb": "" //缩略图地址
      },
      {
        "alt": "请购审批流程",
        "pid": 24, //图片id
        "src": "img/cg.png", //原图地址
        "thumb": "" //缩略图地址
      },
      {
        "alt": "出差报销流程",
        "pid": 25, //图片id
        "src": "img/ccbx.png", //原图地址
        "thumb": "" //缩略图地址
      },
      {
        "alt": "现金报销流程",
        "pid": 26, //图片id
        "src": "img/xjbx.png", //原图地址
        "thumb": "" //缩略图地址
      },
      {
        "alt": "招待报销流程",
        "pid": 27, //图片id
        "src": "img/zdbx.png", //原图地址
        "thumb": "" //缩略图地址
      },
      {
        "alt": "财务审批流程",
        "pid": 28, //图片id
        "src": "img/cwsp.png", //原图地址
        "thumb": "" //缩略图地址
      },
      {
        "alt": "产品转化",
        "pid": 29, //图片id
        "src": "img/zh.png", //原图地址
        "thumb": "" //缩略图地址
      },
      {
        "alt": "项目架构",
        "pid": 30, //图片id
        "src": "img/jg.png", //原图地址
        "thumb": "" //缩略图地址
      },
      {
        "alt": "项目运作",
        "pid": 31, //图片id
        "src": "img/yz.png", //原图地址
        "thumb": "" //缩略图地址
      },
      {
        "alt": "项目流程化",
        "pid": 32, //图片id
        "src": "img/lc.png", //原图地址
        "thumb": "" //缩略图地址
      },
      {
        "alt": "OKR项目资源管理",
        "pid": 33, //图片id
        "src": "img/pokr.png", //原图地址
        "thumb": "" //缩略图地址
      }
    ]
  };
  layer.photos({
    photos: json, //格式见API文档手册页
    anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机
  });
}


function clearNoNum(obj) {
  obj.value = obj.value.replace(/[^\d.]/g, ""); //清除“数字”和“.”以外的字符
  obj.value = obj.value.replace(/\.{2,}/g, "."); //只保留第一个. 清除多余的   
  obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
  obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3'); //只能输入两个小数   
  if (obj.value.indexOf(".") < 0 && obj.value != "") { //以上已经过滤，此处控制的是如果没有小数点，首位不能为类似于 01、02的金额  
    obj.value = parseFloat(obj.value);
  }
  //如果超过最大值则返回 maxValue
  var maxValue = $(obj).attr("max");
  if (maxValue != undefined && maxValue != "undefined" && maxValue != null) {
    if (Number(obj.value) > Number(maxValue)) {
      $(obj).val(maxValue);
    }
  }
}

function banInputSapce(e,_input) {
  var keynum;
  if (window.event) {
    keynum = e.keyCode
  } else if (e.which) {
    keynum = e.which
  }
  if (keynum == 32) {
    var _value = $(_input).val();
    if (_value!=undefined&&_value!=null&&_value!=""){
        var firstChar = _value.substring(0,1);
        if (firstChar==" "||firstChar==""){
            $(_input).val(_value.substring(1,_value.length));
            return false;
        }
    }
  }
  return true;
}

//只能输入整数
function clearNoNum0(obj) {
    obj.value = obj.value.replace(/[^\d]/g, ""); //清除“数字”以外的字符
    obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '[^0-9]'); //只能输入两个小数
    if (obj.value.indexOf(".") < 0 && obj.value != "") { //以上已经过滤，此处控制的是如果没有小数点，首位不能为类似于 01、02的金额
        obj.value = parseFloat(obj.value);
    }
    //如果超过最大值则返回 maxValue
    var maxValue = $(obj).attr("max");
    if (maxValue != undefined && maxValue != "undefined" && maxValue != null) {
        if (Number(obj.value) > Number(maxValue)) {
            $(obj).val(maxValue);
        }
    }
}

function banInputSapce(e,_input) {
    var keynum;
    if (window.event) {
        keynum = e.keyCode
    } else if (e.which) {
        keynum = e.which
    }
    if (keynum == 32) {
        var _value = $(_input).val();
        if (_value!=undefined&&_value!=null&&_value!=""){
            var firstChar = _value.substring(0,1);
            if (firstChar==" "||firstChar==""){
                $(_input).val(_value.substring(1,_value.length));
                return false;
            }
        }
    }
    return true;
}